package info.rflow.graph.util;

import info.rflow.graph.RWorkflowScene;
import org.openide.util.Utilities;

import java.awt.*;
import java.awt.image.BufferedImage;


/**
 * @author Holger Brandl
 */
public class GraphUtils {

    public static void initGrids(RWorkflowScene workflowScene) {
        Image sourceImage = Utilities.loadImage("test/resources/paper_grid17.png"); // NOI18N
        int width = sourceImage.getWidth(null);
        int height = sourceImage.getHeight(null);
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = image.createGraphics();
        graphics.drawImage(sourceImage, 0, 0, null);
        graphics.dispose();
        TexturePaint PAINT_BACKGROUND = new TexturePaint(image, new Rectangle(0, 0, width, height));
        workflowScene.setBackground(PAINT_BACKGROUND);
        workflowScene.repaint();
        workflowScene.revalidate(false);
        workflowScene.validate();
    }
}
